package com.fujitsu.hope.web.common.db;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter {
	private static final SimpleDateFormat FORMATTER = new SimpleDateFormat("yyyyMMdd"); 
	
	public static final Date decode(String date) throws ParseException{
		return FORMATTER.parse(date);
	}
	
	public static final Date decode(int date) throws ParseException{
		if(date == 0){
			return null;
		}else{
			return decode(Integer.toString(date));
		}
	}
	
	public static final String encode(Date date){
		return FORMATTER.format(date);
	}
	
	public static final int encodeInt(Date date){
		return Integer.parseInt(encode(date));
	}
}

